<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>修改密码</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="./layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="./layuiadmin/style/admin.css" media="all">
</head>
<body>
        <div style="padding: 20px;margin:30px 0;line-height: 50px;width:500px">
            <form method="post">
                <input type="hidden" name="method" value="updatePwa">
                旧的密码：<input type="password" name = "paw" id="paw" placeholder="请输入旧密码" size="50px"><br/>
                新的密码：<input type="password" name="newpaw" id="newpaw" placeholder="请输入新密码" size="50px"><br/>
                确认密码：<input type="password" name="rnewpaw" id="rnewpaw" placeholder="请输入新密码" size="50px">
            </form>

<!--            <div class="formbody">-->

<!--                <form action="/UserServlet" method="post" id="fm" target="_top">-->
<!--                    <input  type="hidden" name="oper" value="pwd" />-->
<!--                    <ul class="forminfo">-->
<!--                        <li><label>新密码</label><input name="newPwd" id="newPwd" type="text" class="dfinput" /><i></i></li>-->
<!--                        <li><label>确认密码</label><input name="" id="cfPwd" type="text" class="dfinput" /><i></i></li>-->
<!--                        <li><label>&nbsp;</label><input name="" type="submit" class="btn" value="确认保存"/></li>-->
<!--                    </ul>-->
<!--                </form>-->
<!--            </div>-->

        </div>
        <button hidden class="layui-btn layui-btn-normal" lay-submit lay-filter="paw-submit" id="paw-submit">确认保存</button>
</body>
<script src="http://code.jquery.com/jquery-2.1.1.min.js"></script>
<script src="./layuiadmin/layui/layui.js"></script>
<script>
    layui.config({
        base: './layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'form'], function() {
        var $ = layui.$
            , form = layui.form;

        //监听提交
        form.on('button(paw-submit)', function(data) {
            var field = data.field; //获取提交的字段
            // var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引

            //提交 Ajax 成功后，关闭当前弹层并重载表格
            $.ajax({
                url: '/change',
                data: field,
                type: 'post',
                dataType: 'json',
                success: function (result) {
                    if (result.code == 0) {
                        //添加成功
                        layer.msg('修改成功', {
                            offset: '15px'
                            , icon: 1
                            , time: 200
                        }, function () {
                            // parent.layui.reload("LAY-app-warehouse-list");//重载表格
                            // parent.layer.close(index);//关闭当前的iframe
                            window.location.href = "/login";//跳回main页面
                        });
                    } else if (result.code == 1) {
                        layer.open({
                            title: '提示'
                            , content: result.msg
                        });
                    }
                }
            })
        })
    });

    // $(function(){
    //     //校验密码修改
    //     $("#fm").submit(function(){
    //         if($("#newPwd").val()==""){//校验新密码
    //             alert("新密码不能为空");
    //             return false;
    //         }else if($("#cfPwd").val()==""){//校验确认密码
    //             alert("确认密码不能为空");
    //             return false;
    //         }else if($("#newPwd").val()!=$("#cfPwd").val()){//校验新密码和确认密码是否一致
    //             alert("两次密码 不一致");
    //             return false;
    //         }else{
    //             return true;
    //         }
    //     })
    // })

</script>
</html>